package com.digitalgeko.pruebasdeconcepto;

import android.app.*;
import android.content.pm.*;
import android.os.*;
import android.view.*;

import com.digitalgeko.pruebasdeconcepto.complements.*;
import com.digitalgeko.pruebasdeconcepto.fragments.*;

public class FragmentActivity extends android.support.v4.app.FragmentActivity {

	private android.support.v4.app.FragmentManager fragmentManager;
	private android.support.v4.app.FragmentTransaction fragmentTransaction;
	private android.support.v4.app.Fragment firstFragment;
	
	private DetailFragment newFragment = new DetailFragment();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.fragment);
		
		fragmentManager = getSupportFragmentManager();
		fragmentTransaction = fragmentManager.beginTransaction();
		
		firstFragment = fragmentManager.findFragmentById(R.id.fragmentFirst);
	}
	
	public void changeFragment(View v){
		fragmentTransaction.hide(firstFragment);
		//esto no elimina lo que ya esta
		fragmentTransaction.add(R.id.frameFragments, newFragment);
		
		//esto realmente agrega back al fragment
		fragmentTransaction.addToBackStack(null);
		fragmentTransaction.commit();
	}
	
}
